package se.miun.dt156g.antonsskafferibestallning;

import java.util.ArrayList;
import java.util.HashMap;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class MultiSourceAdapter extends BaseAdapter{
	
	private final Context context;
	private final ArrayList<String> name;
	private final HashMap<String, Integer> incrementNumber;
	
	public MultiSourceAdapter(Context context, ArrayList<String> name, HashMap<String, Integer> incrementNumber) {
		this.context = context;
		this.name = name;
		this.incrementNumber = incrementNumber;
	}

	@Override
	public int getCount() {
		return name.size();
	}

	@Override
	public Object getItem(int position) {
		return name.get(position);
	}

	@Override
	public long getItemId(int position) {
		return name.indexOf(getItem(position));
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		
		LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		View row = inflater.inflate(R.layout.list_item_increment, parent, false);
		TextView nameText = (TextView) row.findViewById(R.id.itemName);
		TextView incrementNumberText = (TextView) row.findViewById(R.id.incrementNumber);
		nameText.setText(name.get(position));
		incrementNumberText.setText(incrementNumber.get(name.get(position)).toString());
		return row;
	}
	
	

}
